package io_nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 输入输出文件复制
 * Created by butterfly on 2018/6/27.
 */
public class FileReaderDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("E:\\pp3\\effective-Java\\src\\io_nio\\FileReaderDemo.java");
        FileOutputStream fos = new FileOutputStream("E:/pp3/copyDemo.txt");
        byte[] bytes = new byte[32];
        int hasRead = 0;
        try {
            while ((hasRead=fis.read(bytes))>0){
                String s = new String(bytes, 0, hasRead);
                System.out.println(s);
                fos.write(bytes);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            fis.close();
            fos.close();
        }
    }
}
